<template>
	<view class="payOuter">
		<!-- 订单 -->
		<view class="orderOuter">
			<view class="orderItem">
				<text>订单类型</text>
				<text>商品订单</text>
			</view>
			<view class="orderItem">
				<text>订单编号</text>
				<text>{{moneyData.rel[0].source_id}}</text>
			</view>
			<view class="orderItem">
				<text>支付金额</text>
				<text>￥{{moneyData.money}}</text>
			</view>
		</view>

		<!-- 支付 -->
		<view class="pay">
			<!-- 线下支付 -->
			<view class="payItem" @click="offlinePay">
				<view class="payItem_img">
					<image src="../../static/images/iconImg/dzf.png" mode=""></image>
				</view>
				<view class="payItem_c">
					<view class="payItem_c_t">
						线下支付
					</view>
					<view class="payItem_c_b">
						联系客服进行线下
					</view>
				</view>
				<image class="yjt" src="../../static/images/iconImg/yjt.png" mode=""></image>
			</view>
			<!-- 线上支付 -->
			<view class="payItem" @click="onlinePay">
				<view class="payItem_img">
					<image src="../../static/images/iconImg/zf.png" mode=""></image>
				</view>
				<view class="payItem_c">
					<view class="payItem_c_t">
						余额支付
					</view>
					<view class="payItem_c_b">
						账户余额支付
					</view>
				</view>
				<image class="yjt" src="../../static/images/iconImg/yjt.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		serviceApi
	} from '../../api/paiModule/home.js'
	export default {
		data() {
			return {
				info: null,
				moneyData: null,
				payment_id: null
			};
		},
		onLoad(options) {
			this.info = options
		},
		onShow() {
			this.getMoneyInfo({
					ids: this.info.ids,
					method: "payments.checkpay",
					payment_type: parseInt(this.info.type),
					token: uni.getStorageSync('token'),
				}),
				this.getPayInfo()
		},
		methods: {
			async getMoneyInfo(data) {
				const {
					data: res
				} = await serviceApi(data)
				this.moneyData = res.data
			},

			// 获取支付信息列表
			async getPayInfo() {
				const {
					data: res
				} = await serviceApi({
					method: "payments.getlist"
				})
			},

			// 线下支付弹窗
			offlinePay() {
				uni.showModal({
					title: '线下支付说明',
					content: '请联系客服进行线下支付',
					/* success: function(res) {
						if (res.confirm) {
							console.log('点击了确认')
						} else {
							console.log('点击了取消')
						}
					} */
				})

			},

			// 线上支付
			async onlinePay() {
				const {
					data: res
				} = await serviceApi({
					ids: this.moneyData.rel[0].source_id,
					method: "user.pay",
					payment_code: "balancepay",
					payment_type: 1,
					token: uni.getStorageSync('token')
				})
				this.payment_id = res.data.payment_id
				if (res.status) {
					uni.navigateTo({
						url: '/pages/payRes/payRes?payment_id=' + this.payment_id
					})
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	.payOuter {
		height: 93vh;
		background-color: #f8f8f8;
		padding-top: 10px;

		.orderOuter {
			background-color: #fff;

			.orderItem {
				width: 90%;
				padding: 10px;
				border-bottom: 1px solid #f1f1f1;
				font-size: 14px;
				display: flex;
				align-items: center;
				justify-content: space-between;

				&:last-child {
					text {
						&:last-child {
							color: #ea0000;
						}
					}
				}

				&>text {
					&:first-child {
						color: #8a8a8a;
					}
				}
			}
		}

		.pay {
			background-color: #fff;
			margin-top: 10px;
			padding: 10px;
			font-size: 12px;

			.payItem {
				width: 90%;
				display: flex;
				align-items: center;
				border-bottom: 1px solid #f4f4f4;
				padding-bottom: 10px;
				position: relative;
				padding-top: 10px;

				.payItem_img {
					border-right: 1px solid #e6e6e6;
					padding-right: 20px;
					margin-right: 20px;
				}

				.payItem_c {
					.payItem_c_b {
						color: #8a8a8a;
					}
				}

				.yjt {
					width: 16px;
					height: 16px;
					position: absolute;
					right: 0;
				}
			}

			image {
				width: 30px;
				height: 30px;
			}
		}
	}
</style>